Imports KanBan.Pgd.Common
Imports KanBan.Pgd.Domain.ValueObjects

Namespace Session

    Public Class ClientSession

        Public Shared Event ApplicationCultureChanged()
        Public Shared Event UserLoggedOut()

        Private Shared ReadOnly credentialsLock As Object = New Object()

        Private Shared _userCredentials As UserCredentials = New UserCredentials(Guid.Empty, String.Empty, New List(Of Permission))
        Public Shared Property UserCredentials() As UserCredentials
            Get
                SyncLock credentialsLock

                    Return _userCredentials

                End SyncLock
            End Get
            Set(ByVal value As UserCredentials)
                _userCredentials = value
            End Set
        End Property

        Private Shared ReadOnly cultureLock As Object = New Object()

        Private Shared _currentCulture As ApplicationCulture = PgdSettings.GetDefaultCulture()
        Public Shared Property CurrentCulture() As ApplicationCulture
            Get
                SyncLock cultureLock

                    Return _currentCulture

                End SyncLock
            End Get
            Set(ByVal value As ApplicationCulture)
                _currentCulture = value
                RaiseEvent ApplicationCultureChanged()
            End Set
        End Property

        Public Shared Sub Dispose()
            _userCredentials = New UserCredentials(Guid.Empty, String.Empty, New List(Of Permission))
            RaiseEvent UserLoggedOut()
        End Sub

    End Class

End Namespace

